import Vue from 'vue'
/**
 * @description 模板
 */
import template from './tip'

/**
 * @description z-index
 * @type {number}
 */
let index = 1000000

/**
 * @description 提示组件
 * @param options
 * @return {*}
 */
Vue.prototype.$tipMessage = (msg = '', duration = 2000) => {
  index = index + 1
  const Component = Vue.extend(template)
  const tipComponent = new Component({
    data () {
      return {
        content: msg,
        state: false,
        index: index
      }
    },
    created () {
      this.$nextTick(() => {
        this.state = true
      })
    }
  })
  const $tick = tipComponent.$mount()
  document.body.appendChild($tick.$el)
  setTimeout(() => {
    document.body.removeChild($tick.$el)
  }, duration)
}
